package com.cosina.game.crystallight.engine;

import java.util.Iterator;
import java.util.LinkedList;

import android.graphics.Point;

import com.cosina.game.crystallight.engine.util.Time;
import com.cosina.game.crystallight.model.FlyingStuff;

public class FlyingManager implements Time{	
	public LinkedList<FlyingStuff> stuffs = new LinkedList<FlyingStuff>();
	Point toScore = new Point(282,480 - 15);

	public void flyingScore(final int score){
		Point src = new Point(35 + 5,(BattleEngine.field.locationSource().y + 2)*44 + 15);
		FlyingStuff fs = new FlyingStuff(src,toScore,score,new Runnable(){
			public void run(){
				BattleEngine.statistics.battleScoreNeedAddValue += score;
			}
		});
		stuffs.add(fs);
	}
	
	@Override
	public void withTimeGo() {
		Iterator<FlyingStuff> iter = stuffs.iterator();
		while(iter.hasNext()){
			FlyingStuff fs = iter.next();
			fs.withTimeGo();
			if(fs.arrive){
				fs.callback.run();
				iter.remove();
			}
		}
	}
}
